package com.example.securitydemo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.securitydemo.model.po.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Select("select role_name from t_role where role_id in (select role_id from user_role_mapping where user_id in (select user_id from t_user where username = #{username}))")
    List<String> selectUserRoleByUsername(@Param("username") String username);

    @Select("select authority_name from t_authority where authority_id in (select authority_id from user_authority_mapping where user_id in (select user_id from t_user where username = #{username}))")
    List<String> selectUserAuthorityByUsername(@Param("username")String username);
}
